package pl.com.betacom.scjp.j2se5practiceExam;

public class Q22AnimalCreator {

	/**
	 * @param args
	 */
	public static void main(String[] args) {
		Animal_[] animals = { new Animal_(), new Cow() };
		for (Animal_ a : animals) {
			Animal_ x = a.getAnimal();
			System.out.println(x);
		}
	}

}

class Animal_ {
	Animal_ getAnimal() {
		return new Animal_();
	}
}

class Cow extends Animal_ {

	Cow getAnimal() { // This is a valid overload
		return new Cow();
	}

	Cow getAnimal(boolean dummy) { // Just some test
		return new Cow();
	}
}

class Horse extends Animal_ {
	// This will fail
//	int getAnimal() {
//		return 0;
//	}

	// This is ok
	int getAnimal(boolean dummy) {
		return 0;
	}
}